import { createRouter, createWebHistory } from 'vue-router'

//后台首页子路由
const childrenRoute = [
    {
        path: "/user",
        name: "user",
        meta: { title: "登录" },
        component: () =>
            import ('@/views/UserList.vue')
    },
    {
        path: "/setting",
        name: "setting",
        meta: { title: "设置" },
        component: () =>
            import ('@/views/Setting.vue')
    }
];

//4 :定义路由配置规则
const routes = [
    {
        path: "/",
        name: "index",
        meta: { title: "首页" },
        component: () =>
            import ('@/views/Index.vue'),
        children: childrenRoute
    },
    {
        path: "/login",
        name: "login",
        meta: { title: "登录" },
        component: () =>
            import ('@/views/Login.vue')
    }
];


//2 :创建路由对象
const router = createRouter({
    // 引入访问模式
    history: createWebHistory(),
    routes
})




// 3: 导出即可生效
export default router